//
//  LJLMyVC.m
//  聆听FM
//
//  Created by dllo on 16/6/14.
//  Copyright © 2016年 Dark. All rights reserved.
//

#import "LJLMyVC.h"
#import "LJLMyButtonIV.h"
#import "LJLMyCollectionVC.h"
#import "LJLDisclaimerVC.h"

#import "LTFileManager.h"
#import "LTCollectListenViewController.h"
#import "LJLSubscribeVC.h"
@interface LJLMyVC ()

@property(nonatomic, strong)LJLMyButtonIV *subscribeIV;
@property(nonatomic, strong)LJLMyButtonIV *focusIV;
@property(nonatomic, strong)LJLMyButtonIV *clearTheCacheIV;
@property(nonatomic, strong)LJLMyButtonIV *versionInformationIV;
@property(nonatomic, strong)LJLMyButtonIV *disclaimerIV;

@end

@implementation LJLMyVC

- (void)didBackImage:(UITapGestureRecognizer *)tap
{
    [self.navigationController popViewControllerAnimated:NO];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 35, 24, 24)];
    imageView.userInteractionEnabled = YES;
    imageView.image = [UIImage imageNamed:@"返回我的"];
    [self.view addSubview:imageView];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didBackImage:)];
    [imageView addGestureRecognizer:tap];
    
    
    self.view.backgroundColor = [UIColor clearColor];
    self.subscribeIV = [[LJLMyButtonIV alloc] initWithFrame:CGRectMake(50 * FITWIDTH, 164 * FITHEIGHT, 275 * FITWIDTH, 40 * FITHEIGHT)];
    self.subscribeIV.userInteractionEnabled = YES;
    self.subscribeIV.picIV.userInteractionEnabled = YES;
    self.subscribeIV.textL.userInteractionEnabled = YES;
    self.subscribeIV.layer.cornerRadius = 10;
    self.subscribeIV.image = [UIImage imageNamed:@"navbar"];
    self.subscribeIV.picIV.image = [UIImage imageNamed:@"recommend"];
    self.subscribeIV.textL.text = @"我   的   订   阅";
    
    UITapGestureRecognizer *subscribeTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didClickedToSubscribe:)];
    [self.subscribeIV.textL addGestureRecognizer:subscribeTap];
    [self.view addSubview:_subscribeIV];
    
    self.focusIV = [[LJLMyButtonIV alloc] initWithFrame:CGRectMake(50 * FITWIDTH, 224 * FITHEIGHT, 275 * FITWIDTH, 40 * FITHEIGHT)];
    self.focusIV.userInteractionEnabled = YES;
    self.focusIV.picIV.userInteractionEnabled = YES;
    self.focusIV.textL.userInteractionEnabled = YES;
    self.focusIV.layer.cornerRadius = 10;
    self.focusIV.image = [UIImage imageNamed:@"navbar"];
    self.focusIV.picIV.image = [UIImage imageNamed:@"关注"];
    self.focusIV.textL.text = @"我   关   注   的";
    UITapGestureRecognizer *focusTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didClickedToFocus:)];
    [self.focusIV.textL addGestureRecognizer:focusTap];
    [self.view addSubview:_focusIV];
    
    self.clearTheCacheIV = [[LJLMyButtonIV alloc] initWithFrame:CGRectMake(50 * FITWIDTH, 284 * FITHEIGHT, 275 * FITWIDTH, 40 * FITHEIGHT)];
    self.clearTheCacheIV.userInteractionEnabled = YES;
    self.clearTheCacheIV.picIV.userInteractionEnabled = YES;
    self.clearTheCacheIV.textL.userInteractionEnabled = YES;
    self.clearTheCacheIV.layer.cornerRadius = 10;
    self.clearTheCacheIV.image = [UIImage imageNamed:@"navbar"];
    self.clearTheCacheIV.picIV.image = [UIImage imageNamed:@"清除"];
    self.clearTheCacheIV.textL.text = @"清   除   缓   存";
    UITapGestureRecognizer *clearTheCacheTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didClickedToClearTheCache:)];
    [self.clearTheCacheIV.textL addGestureRecognizer:clearTheCacheTap];
    [self.view addSubview:_clearTheCacheIV];
    
    self.versionInformationIV = [[LJLMyButtonIV alloc] initWithFrame:CGRectMake(50 * FITWIDTH, 344 * FITHEIGHT, 275 * FITWIDTH, 40 * FITHEIGHT)];
    self.versionInformationIV.userInteractionEnabled = YES;
    self.versionInformationIV.picIV.userInteractionEnabled = YES;
    self.versionInformationIV.textL.userInteractionEnabled = YES;
    self.versionInformationIV.layer.cornerRadius = 10;
    self.versionInformationIV.image = [UIImage imageNamed:@"navbar"];
    self.versionInformationIV.picIV.image = [UIImage imageNamed:@"版本"];
    self.versionInformationIV.textL.text = @"版   本   信   息";
    UITapGestureRecognizer *versionInformationTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didClickedToVersionInformation:)];
    [self.versionInformationIV.textL addGestureRecognizer:versionInformationTap];
    [self.view addSubview:_versionInformationIV];
    
    self.disclaimerIV = [[LJLMyButtonIV alloc] initWithFrame:CGRectMake(50 * FITWIDTH, 404 * FITHEIGHT, 275 * FITWIDTH, 40 * FITHEIGHT)];
    self.disclaimerIV.userInteractionEnabled = YES;
    self.disclaimerIV.picIV.userInteractionEnabled = YES;
    self.disclaimerIV.textL.userInteractionEnabled = YES;
    self.disclaimerIV.layer.cornerRadius = 10;
    self.disclaimerIV.image = [UIImage imageNamed:@"navbar"];
    self.disclaimerIV.picIV.image = [UIImage imageNamed:@"声明"];
    self.disclaimerIV.textL.text = @"免   责   声   明";
    UITapGestureRecognizer *disclaimerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didClickedToDisclaimer:)];
    [self.disclaimerIV.textL addGestureRecognizer:disclaimerTap];
    [self.view addSubview:_disclaimerIV];
}
- (void)viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBar.hidden = YES;
}

#pragma mark -- 我的订阅
- (void)didClickedToSubscribe:(UITapGestureRecognizer *)tap
{
    LJLSubscribeVC *ltCollect = [[LJLSubscribeVC alloc] init];
    [self.navigationController pushViewController:ltCollect animated:YES];
}
#pragma mark -- 我关注的
- (void)didClickedToFocus:(UITapGestureRecognizer *)tap
{
    LJLMyCollectionVC *vc = [[LJLMyCollectionVC alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
}
#pragma mark -- 清除缓存
- (void)didClickedToClearTheCache:(UITapGestureRecognizer *)tap
{
    NSString *cache = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
    NSString *tempString = [NSString stringWithFormat:@"当前缓存共%.1lfM 是否清除缓存", [LTFileManager getNumberWithFilePath:cache] / 1000000.0];
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:tempString preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *action = [UIAlertAction actionWithTitle:@"清除" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [LTFileManager clearDiskWithFilePath:cache];
        [MBProgressHUD showSuccess:@"缓存清理完成"];
    }];
    UIAlertAction *actionCancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
    }];
    [alertController addAction:action];
    [alertController addAction:actionCancel];
    [self showDetailViewController:alertController sender:nil];
}
#pragma mark -- 版本信息
- (void)didClickedToVersionInformation:(UITapGestureRecognizer *)tap
{
    NSLog(@"版本信息");
    LJLDisclaimerVC *dvc = [[LJLDisclaimerVC alloc] init];
    dvc.page = 2;
    dvc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:dvc animated:YES];
}
#pragma mark -- 免责声明
- (void)didClickedToDisclaimer:(UITapGestureRecognizer *)tap
{
    NSLog(@"免责声明");
    LJLDisclaimerVC *dvc = [[LJLDisclaimerVC alloc] init];
    dvc.page = 1;
    dvc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:dvc animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
